<?php
namespace entity;
use my\bq\entity\EntityTemplate;
use my\bq\dao\DaoTemplate;

use my\bq\criterion\FiledTranslater;
use my\bq\criterion\property;
use my\bq\criterion\Relation;
use my\bq\criterion\Group;
use my\bq\criterion\Order;
use my\bq\criterion\LogicalExpression;
use my\bq\criterion\SimpleExpression;
use my\bq\criterion\CriteriaImpl;
use my\bq\criterion\InExpression;
use my\bq\criterion\Criteria;
use my\bq\criterion\Restrictions;
use my\bq\criterion\CriteriaQuery;
use my\bq\criterion\Projections;
use my\bq\criterion\Join;



class MyService extends DaoTemplate{
	

	//查看风格频道
	public function findStyle(){
		$styleOfCrit = new CriteriaImpl(new Style());
		$styleOfCrit->setFileds("*"); //要查询的字段
		$styleOfCrit->setFirstResult(2); //起始编号。
		$styleOfCrit->setFetchSize(3); //记录条数。
		return $this->find($styleOfCrit);
	}
	//查看商品
	public function findGoods(){
		$goodsOfCrit = new CriteriaImpl(new Goods());
		$userCrit = $goodsOfCrit->createCriteria(new User());
		$goodsOfCrit->addJoin(Join::add($userCrit, "store_id", "user_id", Criteria::JOIN));
		$goodsOfCrit->setFileds("*"); //要查询的字段
		$goodsOfCrit->setFirstResult(0); //起始编号。
		$goodsOfCrit->setFetchSize(1); //记录条数。
		return $this->find($goodsOfCrit);
	}

	//查看用户
	public function findUser(){
		$userOfCrit = new CriteriaImpl(new User());
		$userOfCrit->setFileds("*"); //要查询的字段
		$userOfCrit->setFirstResult(2); //起始编号。
		$userOfCrit->setFetchSize(3); //记录条数。
		return $this->find($userOfCrit);
	}

	
	public function listStyle($crit){
		return $this->findAll($crit);
	}
	
	//common
	public function saveStyle($entity){
		return $this->save($entity);
	}
	
	public function updateStyle($entity){
		return $this->update($entity);
	}
	
	public function deleteStyle($entity){
		return $this->delete($entity);
	}	
}